home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / dos_win / winsock / maillist / 94-04.Z / 94-04 / text0278.txt < prev    next >
Encoding:
Text File  |  1994-04-30  |  3.7 KB  |  78 lines

  1. In article <2ou52f$636@caladan.restena.lu> Kries Roger <kries@crpht.lu> writes:
  2. |I'm having some problems writing Berkley Sockets API compatible code to
  3. |connect to a machine with a timeout value. That's to say, I want to
  4. |connect to a machine, but if I cannot connect until the timeout is
  5. |elapsed I give up.
  6. |
  7. |My solution was to call connect() on a non-blocking socket and then to
  8. |call select() with the timeout value and to check if the socket is
  9. |writeable.
  10. [...]
  11. |All this seems to be very fine, but after testing the method on
  12. |a PC with Trumpet Winsock.dll, on a macintosh with a special socket
  13. |library (GUSI) and on a HP-UX machine, the following problem arises:
  14. |
  15. | If at the moment of the connect call, the remote machine has no socket
  16. | created that listens to the specified port, the following select() call
  17. | will always timeout, even if during the timeout interval a program is
  18. | started that listens to the port. That means that in the case where a
  19. | blocking connect call would return ECONNREFUSED, a non-blocking returns
  20. | WSAWOULDBLOCK, but the select call always timeouts.
  21.  
  22. Which fd_set are you putting the sock into for the select call?
  23. To detect a successful connect(), you need the sock in 'writefds',
  24. and to check an unsuccessful connect() you need the socket in 'exceptfds'.
  25.  
  26. Assuming you are doing both of these, 
  27. This is broken behaviour - do all the platforms you have tested with
  28. act this way?
  29.  
  30. If there is no listener on the remote machine, the non-blocking connect()
  31. can't tell, so returning error WSAEWOULDBLOCK is correct.
  32. You then call select(), with the socket of interest in both 'writefds' and 
  33. 'exceptfds',and as soon as the RST arrives back, your select should
  34. return with the socket in exceptfds marked.
  35.  
  36. On another note, I have seen recommended in a few places that connect()
  37. should NOT return immediately it gets back a RST, with WSAECONNREFUSED -
  38. it should keep trying, just as it would if there was no response at all,
  39. and return WSAECONNREFUSED after the normal timeout time. This
  40. guards against connections failing purely because of a loss of
  41. synchronisation, where the server was just a little too slow to
  42. get the socket listening before the client tries to connect. The
  43. first SYN may cause a RST to come back, but the next attempt
  44. should catch the listener finally up and running.
  45.  
  46. -- 
  47. Paul Brooks              |paul@abccomp.oz.au       |Emerging Standard:
  48. TurboSoft Pty Ltd        |pwb@newt.phys.unsw.edu.au|  one that has not yet
  49. 579 Harris St., Ultimo   |                         |  been superseded.
  50. Sydney Australia 2007    |ph: +61 2 281 3155       |  
  51. From news@bigblue.oit.unc.edu Tue Apr 22 12:17:01 1994
  52. Received: from bigblue.oit.unc.edu by SunSITE.Unc.EDU (5.65c+IDA/FvK-1.07) with SMTP
  53.           id AA01788; Sun, 24 Apr 1994 12:44:32 -0400
  54. Received: by bigblue.oit.unc.edu (AIX 3.2/UCB 5.64/4.03)
  55.           id AA32224; Sun, 24 Apr 1994 11:12:19 -0500
  56. Received: from GATEWAY by bigblue with netnews
  57.     for winsock@sunsite.unc.edu (winsock@sunsite.unc.edu)
  58. To: winsock@sunsite.unc.edu
  59. Date: 22 Apr 1994 12:17:01 GMT
  60. From: frank@e-technik.tu-ilmenau.de (Frank Becker)
  61. Message-Id: <2p8f7t$4a@prakinf2.PrakInf.TU-Ilmenau.DE>
  62. Organization: Resumix, Inc., Santa Clara, CA
  63. Sender: ses
  64. Reply-To: frank@e-technik.tu-ilmenau.de
  65. Subject: PCNFS 4.0 and winsock.dll ??
  66.  
  67. I've installed Sun-PC-NFS 4.0 and Windows 3.1. Then I wanted to use NCSA Mosaic 2.0a4.
  68. Therefore I needed winsock.dll. I tried different versions of winsock.dll, but if I start Mosaic a message appear "failed initialize winsock.dll".
  69. I know a configuration with PC-NFS 5.0 and WfW 3.11 works very fine.
  70. Who knows about the problem of interworking between PC-NFS 4.0 and winsock.dll??
  71. Do I have to setup my winsock.dll (I copied the file in my NFS-directory)??
  72. What is wrong??
  73.  
  74. Thank you Frank 
  75.  
  76.  
  77.  
  78.